<?php

namespace app\models;

/**
 * This is the model class for table "{{%config}}".
 *
 * @property int $id ID
 * @property string $name 配置名称
 * @property string $value 配置内容
 * @property string $type text文本 img图片数组 json键值对
 * @property string|null $description 配置描述
 */
class Config extends \app\models\ActiveRecord
{
    const SYSTEM_CONFIG = 'systemConfig';
    const BUSINESS_PARAMS_CONFIG = 'businessConfig';

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%config}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'value', 'type'], 'required'],
            [['value'], 'string'],
            [['name'], 'string', 'max' => 50],
            [['type'], 'string', 'max' => 10],
            [['description'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '配置名称',
            'value' => '配置内容',
            'type' => 'text文本 img图片数组 json键值对',
            'description' => '配置描述',
        ];
    }

    /**
     * 批量插入字段
     * @return array
     */
    public static function columns()
    {
        return [
            'name',
            'value',
            'type',
            'description',
        ];
    }

    /**
     * Notes:获取系统中文映射
     * Date: 2020/7/28
     * Time: 15:22
     * @return array
     */
    public static function getSystemMapping()
    {
        return [
            self::SYSTEM_CONFIG => '系统基本设置',
            self::BUSINESS_PARAMS_CONFIG => '业务基本设置',
        ];
    }

    /**
     * Notes:获取系统设置key
     * Date: 2020/7/28
     * Time: 15:22
     * @return array
     */
    public static function getSystemModule()
    {
        return [
            self::SYSTEM_CONFIG,
            self::BUSINESS_PARAMS_CONFIG
        ];
    }


    /**
     * Notes:获取系统设置key
     * Date: 2020/7/28
     * Time: 15:22
     * @return array
     */
    public static function getSystemKey()
    {
        return [
            self::SYSTEM_CONFIG => 'system_config',
            self::BUSINESS_PARAMS_CONFIG => 'business_params_config',
        ];
    }


}